<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
	</body>
	<script type="text/javascript">
		var data = [{
				"id": 1,
				"age": 22,
				"name": "Alice"
			},
			{
				"id": 3,
				"age": 20,
				"name": "Dick"
			},
			{
				"id": 2,
				"age": 22,
				"name": "Jam"
			},
			{
				"id": 4,
				"age": 28,
				"name": "Tom"
			}
		]

		data = data.sort((o1, o2) => {
			if(o1.age != o2.age) {
				return o1.age - o2.age;
			}
			return  o2.id-o1.id;
		});
		console.log(data);
	</script>

</html>